# -*- coding:utf-8 -*-

import redis


class re:
    def __init__(self, parm=None):
        # reparm = (parm or ('192.168.1.5', 6379, 0))
        reparm = (parm or ('127.0.0.1', 6379, 0))
        self.redis = redis.Redis(host=reparm[0], port=reparm[1], db=reparm[2])

    #  开启pipeline模式
    def re_batch(self, func):
        def wrapper(*args, **kw):
            c = args[0].conn
            pipe = c.pipeline()
            kw["pipe"] = pipe
            func(*args, **kw)
            result = pipe.execute()
            return result
        return wrapper